{% extends "layouts" ~ DIR ~ "default.twig" %}

{% block title %}{{ "Manage Pages" | translate }}{% endblock %}

{% block content %}
<form class="filters" action="{{ url('manage_pages') }}" method="post" accept-charset="UTF-8" role="search">
<fieldset role="presentation">
<label for="query">
{{ "Search&hellip;" | translate }}
<a href="{{ url('help/id/filtering_results') }}" rel="help" target="_blank" class="help emblem">
{{- icon_svg("help.svg", "Help" | translate) -}}
</a>
</label>
<input class="text filter_text" type="text" name="query" value="{{ GET.query | fix(true, true) }}" id="query">
<button type="submit">{{ "Search" | translate }}</button>
{% if visitor.group.can("add_page") %}
<a href="{{ url('write_page') }}" class="button yay">
{{ icon_svg("add.svg") }}{{ "New Page" | translate }}
</a>
{% endif %}
</fieldset>
</form>
<h2>{{ GET.query is not empty ? "Search Results" | translate : "Pages" | translate }}</h2>
<table>
<thead>
<tr class="head">
<th class="page_title title main">{{ "Title" | translate }}</th>
<th class="page_created date">{{ "Created" | translate }}</th>
<th class="page_updated date">{{ "Last Updated" | translate }}</th>
<th class="page_public emblem">{{ "Public?" | translate }}</th>
<th class="page_show emblem">{{ "Listed?" | translate }}</th>
<th class="page_author value">{{ "Author" | translate }}</th>
{{ trigger.call("manage_pages_column_header") }}
<th class="controls" colspan="2">{{ "Controls" | translate }}</th>
</tr>
</thead>
<tbody>
{% for page in pages.paginated %}
<tr id="page_{{ page.id }}" class="page">
<td class="page_title title main">
<a href="{{ page.url() }}">{{ page.title | striptags | oneof("[Untitled]" | translate) | truncate(40) }}</a>
</td>
<td class="page_created date">
{{ page.created_at | time }}
</td>
<td class="page_updated date">
{% if page.updated %}
{{ page.updated_at | time }}
{% else %}
{{ "Never" | translate }}
{% endif %}
</td>
<td class="page_public emblem">
{% if page.public %}
{{ icon_svg("success.svg", "Yes" | translate, "emblem") }}
{% endif %}
</td>
<td class="page_show emblem">
{% if page.show_in_list %}
{{ icon_svg("success.svg", "Yes" | translate, "emblem") }}
{% endif %}
</td>
<td class="page_author value">
{{ page.author.name | fix(false, true) }}
</td>
{{ trigger.call("manage_pages_column", page) }}
<td class="controls">
{%- if visitor.group.can("edit_page") -%}
{{ page.edit_link(icon_svg("edit.svg", "Edit" | translate), null, null, "emblem") }}
{%- else -%}
{{ icon_svg("forbidden.svg", false, "emblem forbidden") }}
{%- endif -%}
</td>
<td class="controls">
{%- if visitor.group.can("delete_page") -%}
{{ page.delete_link(icon_svg("delete.svg", "Delete" | translate), null, null, "emblem") }}
{%- else -%}
{{ icon_svg("forbidden.svg", false, "emblem forbidden") }}
{%- endif -%}
</td>
</tr>
{% else %}
<tr>
<td class="placeholder">
{{ icon_svg("failure.svg", false, "emblem") }}
{{ "No results" | translate }}
</td>
</tr>
{% endfor %}
</tbody>
</table>
{% if pages.paginated is not empty and pages.pages > 1 %}
<div class="pagination">
<span class="pages">{{ "Page %d of %s" | translate | format(pages.page, pages.final_link(pages.pages)) }}</span>
{{ pages.prev_link }}
{{ pages.next_link }}
</div>
{% endif %}
{% endblock %}
